<!DOCTYPE html>
<html>
  <head>
    <title>注册</title>
    <link href="/stylesheets/style.css" rel="stylesheet" />
  </head>
  <body>
    <ul>
      <li><a  href="/">Home</a></li>
      <li><a href="login">立即登录</a</li>
      <li><a href="logout">退出登录</a></li>
      <li><a class="active" href="regist">立即注册</a></li>
    </ul>
    <div class="form-box">
        <form action="/users/regist" method="post" enctype="multipart/form-data">
            <input type="text" name="username" value="" placeholder="请输入用户名">
            <input type="password" name="password" value="" placeholder="请输入密码">
            <div class="group">
              <input type="text" name="thumb" onclick="photo.click();" placeholder="请上传头像" >
              <img name="imgshow" onclick="photo.click();"> 
              <input type="file" name="photo" style='display:none' onchange="{thumb.value=this.value;}" >
            </div>
            <input type="submit" name="" value="注册">
        </form>
        <div>已有帐号， <a href="/login">立即登录</a></div>
    </div>
  </body>
  <script> 
    let img=document.getElementsByTagName("img")[0];
    let photo=document.getElementsByName("photo")[0];
    photo.addEventListener("change",changeHandler);
    function changeHandler(){		
      img.src=window.URL.createObjectURL(photo.files[0]);
    }
    </script>
</html>